
export default {
  setHeaderTitle(state, type) {
    switch (type) {
      case 'day':
        state.headerTitle = '当天信息'
        break
      case 'month':
        state.headerTitle = '近期假期'
        break
      case 'year':
        state.headerTitle = '当年假期'
        break
    }
  },
  setPlaceholder(state, type) {
    const dt = new Date()
    const year = dt.getFullYear()
    const month = (dt.getMonth() + 1 + '').padStart(2, '0')
    const day = (dt.getDate() + '').padStart(2, 20)
    switch (type) {
      case 'day':
        state.placeholder = `格式:  ${year}${month}${day}(${year}年${month}月${day}日)`
        break
      case 'month':
        state.placeholder = `格式:  ${year}${month}(${year}年${month}月)`
        break
      case 'year':
        state.placeholder = `格式:  ${year}(${year}年)`
        break
    }
  },
  setMaxlength(state, type) {
    switch (type) {
      case 'day':
        state.maxlength = 8
        break
      case 'month':
        state.maxlength = 6
        break
      case 'year':
        state.maxlength = 4
        break
    }
  },
  setErrorCode(state, num) {
    state.errorCode = num
  },
  setType(state, type) {
    state.type = type
  },
  setData(state, payload) {
    const { type, data } = payload
    console.log(data)
    switch (type) {
      case 'day':
        state.dayData = data
        break
      case 'month':
        state.monthData = data
        break
      case 'year':
        state.yearData = data
    }
  },
  setSearchText(state, value) {
    state.searchText = value
  }
}
